home *** CD-ROM | disk | FTP | other *** search
/ Champak 99 / (Vol 99) Jan 19 2010.iso / Games / balls.swf / scripts / DefineSprite_49 / frame_1 / DoAction.as
Encoding:
Text File  |  2010-01-19  |  932 b   |  57 lines

  1. this.dx = random(10) - 5;
  2. this.dy = random(10) - 5;
  3. r = 15;
  4. h = 450;
  5. _root.maxim = 6;
  6. stop();
  7. this.onEnterFrame = function()
  8. {
  9.    if(this._x + r < h && this._x - r > 0)
  10.    {
  11.       this._x += this.dx;
  12.    }
  13.    else
  14.    {
  15.       this.dx *= -1;
  16.       this._x += dx;
  17.       if(_X - r < 0)
  18.       {
  19.          _X = 2 + r;
  20.       }
  21.       if(_X + r > h)
  22.       {
  23.          _X = h - 2 - r;
  24.       }
  25.    }
  26.    if(this._y + r < h && this._y - r > 0)
  27.    {
  28.       this._y += this.dy;
  29.    }
  30.    else
  31.    {
  32.       this.dy *= -1;
  33.       this._y += dy;
  34.       if(_Y - r < 0)
  35.       {
  36.          _Y = 2 + r;
  37.       }
  38.       if(_Y + r > h)
  39.       {
  40.          _Y = h - 2 - r;
  41.       }
  42.    }
  43.    v = Math.sqrt(dx * dx + dy * dy);
  44.    if(v < _root.maxim)
  45.    {
  46.       dx *= 1.01;
  47.       dy *= 1.01;
  48.    }
  49.    else if(v > _root.maxim)
  50.    {
  51.       dx *= 0.98;
  52.       dy *= 0.98;
  53.    }
  54.    _root.maxim *= 1.00006;
  55.    trace(_root.maxim);
  56. };
  57.